package top.aicey.ai.sparring;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.baomidou.mybatisplus.generator.fill.Column;

import top.aicey.ai.sparring.entity.BaseEntity;

public class MyFastAutoGenerator {

    public static void main(String[] args) {


        FastAutoGenerator.create("jdbc:mysql://121.43.236.15:3306/sparring?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&serverTimezone=Asia/Shanghai&remarks=true&useInformationSchema=true", "sparring", "Sparring@0910")
                // 全局配置
                .globalConfig((scanner, builder) -> builder.author("白杨"))
                // 包配置
                .packageConfig((scanner, builder) -> builder.parent("top.aicey.ai.sparring"))
                // 策略配置
                .strategyConfig((scanner, builder) -> builder.addTablePrefix("system").addInclude(getTables(scanner.apply("请输入表名，多个英文逗号分隔？所有输入 all")))
                        .entityBuilder()
                        .enableLombok()
                        .addIgnoreColumns("")
                        .idType(IdType.AUTO)
                        .superClass(BaseEntity.class)
                        .addIgnoreColumns("created_by","created_at","updated_by","updated_at")
                        .build())
                // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }

    // 处理 all 情况
    protected static List<String> getTables(String tables) {
        return "all".equals(tables) ? Collections.emptyList() : Arrays.asList(tables.split(","));
    }
}
